#ifndef Config_H_
#define Config_H_

/**/
#define ClearVariable(var_2_clr) memset(var_2_clr,0,sizeof(var_2_clr));

/**/
#define USE_COOS	0
/* definitions for USARTx*/
#define USARTTerm 	USART1
//#define CONNECT_SOFTWARE 0

/* define USART echo mode, echo mode is disable if zero*/
#define USART_Echo	0

/* definitions for OUTx */
#define OUT_LCD   	1
#define OUT_USART 	2

typedef enum {
	CONNECT_SOFTWARE = 0, CONNECT_TERMINAL, CONNECT_KEYPAD,
} CONNECT_type;

typedef enum {
	uSec = 0, mSec, Sec,
} TIM_SET;

typedef enum {
	file_mode = 0, dac_mode, adc_mode, led_mode,
} MODESEL;

typedef enum {
	root_level = 0, func_level,
} lcd_menu_level;

//define keypad for use
#define key_up 		12
#define key_down 	13
#define key_left 	11
#define key_right 	14
#define key_select 	41
#define key_menu	42

#define pi 3.141593

USART_TypeDef* USARTx;

int OUTx;
unsigned int delay_stream;// in millisecond
//#define max_delay_stream 1000
unsigned int flag_export_usart;
unsigned int lcd_current_line;
CONNECT_type FLAG_CONNECT_TYPE;

#define OUTPUT_USARTTerm OUTx = OUT_USART;USARTx = USARTTerm;
#define OUTPUT_LCD		 OUTx = OUT_LCD;

void SetSysClk(void);
void General_Config(void);
void delays(unsigned long dvalue);
void delayus(unsigned long dvalue);
void delayms(unsigned long dvalue);
void ModeSel_Configuration(void);
MODESEL ModeSel(void);
void SwitchUSART1IRQ(FunctionalState state);
void SwitchTIM2IRQ(FunctionalState state);
void SwitchTIM3IRQ(FunctionalState state);
void SwitchTIM4IRQ(FunctionalState state);
void SwitchTIM5IRQ(FunctionalState state);
void SwitchTIM6IRQ(FunctionalState state);
void SwitchSPI2IRQ(FunctionalState state);
void SwitchEXTI2IRQ(FunctionalState state);
void SwitchAllIRQ(FunctionalState state);
void timer2_config(TIM_SET set);
void timer3_config(void);
void timer4_config(unsigned int microsec);
void timer5_config(void);
void timer6_config(void);
//define for easy remember
#define Switch_usartTerm_IRQ(state)		SwitchUSART1IRQ(state)
#define Switch_timer_delay_IRQ(state)	SwitchTIM2IRQ(state)
#define Switch_timer_LED_IRQ(state)		SwitchTIM3IRQ(state)
#define Switch_timer_DAC_IRQ(state)		SwitchTIM4IRQ(state)
#define Switch_timer_ADC_IRQ(state)		SwitchTIM5IRQ(state)
#define Switch_timer_Keypad_IRQ(state)	SwitchTIM6IRQ(state)
#define Switch_SPI_VS10xx_IRQ(state)	SwitchSPI2IRQ(state)
#define timer_delay_config(SET) 		timer2_config(SET)
#define timer_LED_config()				timer3_config()
#define timer_DAC_config(us)			timer4_config(us)
#define timer_ADC_config()				timer5_config()
#define timer_Keypad_config()			timer6_config()
#endif
